package cn.com.code.design;

import com.sun.xml.internal.ws.api.pipe.Engine;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.math.BigDecimal;
import java.util.Scanner;

/**
 * @author zhengpei
 * @date 2022/5/16
 */
public class Hwjs02 {

  public static void main(String[] args) throws ScriptException {
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
      String str = sc.nextLine();
      System.out.println(result(str));
    }
  }

  private static String result(String str) throws ScriptException {
    String[] split = str.split(";");
    String[] str1 = split[0].split(",");
    String[] str2 = split[1].split(",");
    String[] str3 = split[2].split(",");
    String[] str4 = split[3].split(",");
    String[] str5 = split[4].split(",");
    String[] str6 = split[5].split(",");


    Double a = Double.parseDouble(str1[0]) * Double.parseDouble(str4[0]) + Double.parseDouble(str1[1]) * Double.parseDouble(str4[1]) + Double.parseDouble(str1[2]) * Double.parseDouble(str4[2]) + Double.parseDouble(str1[3]) * Double.parseDouble(str4[3]) + Double.parseDouble(str1[4]) * Double.parseDouble(str4[4]) - Double.parseDouble(str5[0]);
    Double b = Double.parseDouble(str2[0]) * Double.parseDouble(str4[0]) + Double.parseDouble(str2[1]) * Double.parseDouble(str4[1]) + Double.parseDouble(str2[2]) * Double.parseDouble(str4[2]) + Double.parseDouble(str2[3]) * Double.parseDouble(str4[3]) + Double.parseDouble(str2[4]) * Double.parseDouble(str4[4]) - Double.parseDouble(str5[1]);
    Double c = Double.parseDouble(str3[0]) * Double.parseDouble(str4[0]) + Double.parseDouble(str3[1]) * Double.parseDouble(str4[1]) + Double.parseDouble(str3[2]) * Double.parseDouble(str4[2]) + Double.parseDouble(str3[3]) * Double.parseDouble(str4[3]) + Double.parseDouble(str3[4]) * Double.parseDouble(str4[4]) - Double.parseDouble(str5[2]);


    double temp1, temp2 = 0;
    if (a > b) {
      temp1 = a;
    } else {
      temp1 = b;
    }

    if (temp1 < c) {
      temp2 = c;
    }

    String value = temp2 + "";
    String result;
    if (value.contains(".")) {
      result = value.split("\\.")[0];
    } else {
      result = value;
    }

    boolean a1, b1, c1;
    
    ScriptEngine javaScript = new ScriptEngineManager().getEngineByName("JavaScript");

    String ss1 = String.valueOf(a).concat(str6[0]);
    Object eval = javaScript.eval(ss1);


    return result;
  }


}
